#include "nameinput.h"

namespace verema
{

nameInput::nameInput()
: vbl_mainLayout(this)
, lbl_info(this)
, led_input(this)
, btn_ok("Erstellen", this)
, btn_cancel("Abbrechen", this)
{
	setFixedSize(300,100);
	setWindowTitle(QString::fromUtf8("Hinzufügen"));
	setWindowModality(Qt::ApplicationModal);
	
	hbl_buttons.addWidget(&btn_ok);
	hbl_buttons.addWidget(&btn_cancel);
	
	vbl_mainLayout.addWidget(&lbl_info);
	vbl_mainLayout.addWidget(&led_input);
	vbl_mainLayout.addLayout(&hbl_buttons);
	
	connect(&btn_cancel, SIGNAL(clicked()), this, SLOT(hide()));
	connect(&btn_ok, SIGNAL(clicked()), this, SLOT(okActivated()));
	connect(&led_input, SIGNAL(returnPressed()), this, SLOT(okActivated()));
}

void nameInput::setMessage(QString message)
{
	lbl_info.setText(message);
}

void nameInput::okActivated()
{
	if(led_input.text().simplified() != "")
	{
		emit okClicked();
		hide();
	}
}

QString nameInput::getInput()
{
	QString result = led_input.text();
	led_input.setText("");
	return(result);
}

} // namespace verema
